﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UAC;
using UAC.Operation;

namespace UACManager
{
    public partial class TeamDefListForm : Form
    {
        public TeamDefListForm()
        {
            InitializeComponent();
        }

        private List<TeamDef> teamDefs;
        private void TeamDefListForm_Load(object sender, EventArgs e)
        {
            teamDefs = Utils.ListTeamDef();
            DataTable result = new DataTable();
            result.Columns.Add("TeamDefID");
            result.Columns.Add("Description");
            result.Columns.Add("TargetDescription");

            if (teamDefs != null)
            {
                foreach (TeamDef teamDef in teamDefs)
                {
                    DataRow dr = result.NewRow();
                    dr[0] = teamDef.TeamDefID;
                    dr[1] = teamDef.Description;
                    dr[2] = teamDef.TargetDescription;
                    result.Rows.Add(dr);
                }
            }
            dataGridViewMain.DataSource = result;
        }

        private void dataGridViewMain_DoubleClick(object sender, EventArgs e)
        {
            if (this.dataGridViewMain.SelectedRows != null && this.dataGridViewMain.SelectedRows.Count > 0)
            {
                int teamDefId = Convert.ToInt32(this.dataGridViewMain.SelectedRows[0].Cells[0].Value.ToString());
                using (TeamRoleDefListForm trdlf = new TeamRoleDefListForm(teamDefId))
                    trdlf.ShowDialog();
            }
        }
    }
}
